package exam.qianxing;

import java.util.ArrayDeque;
import java.util.Deque;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

//简易计算器
public class testb2 {
    public static void main(String[] args) {
        Map<Character,Integer> map = new HashMap<>();
        map.put('-',1);
        map.put('+',1);
        map.put('*',2);
        map.put('/',2);

        Scanner scanner = new Scanner(System.in);
        String input = scanner.next();
        input = input.replaceAll(" ","");
        char [] cs = input.toCharArray();
        int n = input.length();

        Deque<Integer> nums = new ArrayDeque<>();
        Deque<Character> ops = new ArrayDeque<>();
        //nums.addLast(0);

        for (int i = 0; i < n; i++) {
            char c = cs[i];
            if(c=='('){
                ops.addLast(c);
            }else if(c==')'){
                while(!ops.isEmpty()){
                    if(ops.peekLast()!='('){
                        calc(nums,ops);
                    }else{
                        ops.pollLast();
                        break;
                    }
                }
            }else{
                if(Character.isDigit(c)){
                    int u = 0;
                    int j = i;
                    while(j<n&&Character.isDigit(cs[j])){
                        u=u*10+(cs[j++]-'0');
                    }
                    nums.addLast(u);
                    i = j-1;
                }else{
                    if(i>0&&(cs[i-1]=='(')||cs[i-1]=='+'||cs[i-1]=='-'){
                        nums.addLast(0);
                    }

                    while(!ops.isEmpty()&&ops.peekLast()!='('){
                        char pre = ops.peekLast();
                        if(map.get(pre)>=map.get(c)){
                            calc(nums,ops);
                        }else{
                            break;
                        }
                    }
                    ops.addLast(c);
                }
            }
        }

        while(!ops.isEmpty()){
            calc(nums,ops);
        }
        System.out.println(nums.peekLast());
    }

    public static void calc(Deque<Integer> nums,Deque<Character> ops ){
        if(nums.isEmpty()||nums.size()<2){
            return;
        }
        if(ops.isEmpty()){
            return;
        }
        int b = nums.pollLast();
        int a = nums.pollLast();
        char op = ops.pollLast();
        int ans = 0;
        if(op == '+'){
            ans = a+b;
        }else if(op == '-'){
            ans = a-b;
        }else if(op == '*'){
            ans = a*b;
        }else if(op == '/'){
            ans = a/b;
        }
        nums.addLast(ans);
    }
}
